IEEE

Section: C Library Functions (3)
Index Return to Main Contents

BSD mandoc
BSD 4.3  

NAME

copysign drem finite logb scalb copysign remainder, - exponent manipulations  

SYNOPSIS

Fd #include <math.h> Ft double Fn copysign double x double y Ft double Fn drem double x double y Ft int Fn finite double x Ft double Fn logb double x Ft double Fn scalb double x int n  

DESCRIPTION

These functions are required for, or recommended by the IEEE standard 754 for floating-point arithmetic.

The Fn copysign function returns Fa x with its sign changed to Fa y Ns 's.

The Fn drem function returns the remainder Fa r := Fa x - Fa n*y where Fa n is the integer nearest the exact value of -words Fa x Ns / Ns Fa y ; moreover if \*(Ba Fa n - Fa x No / Fa y No \*(Ba = 1/2 then Fa n is even. Consequently the remainder is computed exactly and \*(Ba Fa r \*(Ba \*(Ba Fa y \*(Ba/2. But Fn drem x 0 is exceptional. (See below under Sx DIAGNOSTICS . )

The Fn finite function returns the value 1 just when - Fa x +; otherwise a zero is returned (when \*(Ba Fa x \*(Ba = or Fa x is or is the VAX 's reserved operand).

The Fn logb function returns Fa x Ns 's exponent Fa n , a signed integer converted to double-precision floating-point and so chosen that 1 (<= \*(Ba Fa x \*(Ba2** Fa n < 2 unless Fa x = 0 or (only on machines that conform to IEEE 754) \*(Ba Fa x \*(Ba = or Fa x lies between 0 and the Underflow Threshold. (See below under Sx BUGS . )

The Fn calb returns Fa x Ns *(2** Ns Fa n ) computed, for integer n, without first computing 2* Fa n  

RETURN VALUES

The IEEE standard 754 defines Fn drem x 0 and Fn drem \*(If y to be invalid operations that produce a . On the VAX , Fn drem x 0 generates a reserved operand fault. No exists on a VAX .

IEEE 754 defines Fn logb ±\*(If = and Fn logb 0 = -, and requires the latter to signal Division-by-Zero. But on a VAX , Fn logb 0 = 1.0 - 2.0**31 = -2,147,483,647.0. And if the correct value of Fn scalb would overflow on a VAX , it generates a reserved operand fault and sets the global variable errno to ERANGE .  

SEE ALSO

floor(3), math(3), infnan(3)  

HISTORY

The ieee functions appeared in BSD 4.3  

BUGS

Should Fn drem x 0 and Fn logb 0 on a VAX signal invalidity by setting errno = EDOM Should Fn logb 0 return -1.7e38?

IEEE 754 currently specifies that Fn logb denormalized no. = Fn logb tiniest normalized no. > 0 but the consensus has changed to the specification in the new proposed IEEE standard p854, namely that Fn logb x satisfy

1 < Fn scalb \*(Bax\*(Ba -logb(x) < Radix  ... = 2 for IEEE 754

for every x except 0, and . Almost every program that assumes 754's specification will work correctly if Fn logb follows 854's specification instead.

IEEE 754 requires Fn copysign x \*(Na) = ± Fa x but says nothing else about the sign of a . A N ot a N umber is similar in spirit to the VAX 's reserved operand, but very different in important details. Since the sign bit of a reserved operand makes it look negative,

Fn copysign x reserved operand = - Fa x

should this return the reserved operand instead?


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUES
SEE ALSO
HISTORY
BUGS

This document was created by man2html, using the manual pages.
Time: 00:35:29 GMT, March 30, 2022